package com.xiaoxx.coin.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum TimeInForceEnum {
    GTC("GTC", "Good Till Cancel - 成交为止"),
    IOC("IOC", "Immediate or Cancel - 无法立即成交的部分就撤销"),
    FOK("FOK", "Fill or Kill - 无法全部立即成交就撤销"),
    GTX("GTX", "Good Till Crossing - 无法成为挂单方就撤销"),
    GTD("GTD", "Good Till Date - 在特定时间之前有效，到期自动撤销");
    private final String code;
    private final String description;

    public static TimeInForceEnum ofCode(String code) {
        for (TimeInForceEnum timeInForce : values()) {
            if (timeInForce.getCode().equalsIgnoreCase(code)) {
                return timeInForce;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }
}
